#ifndef _MESHFILTER_H_
#define _MESHFILTER_H_

#include <SERender/Resourses/Mesh.h>
#include <unordered_map>
#include <SECore/Descriptor.h>
#include <string>

namespace SEngine
{
    class MeshFilter : public AnyDescriptor
    {
    public:
        MeshFilter() = default;
        virtual ~MeshFilter() = default;

        void AddMesh(const std::string & name, std::shared_ptr<Mesh> && mesh) { m_meshes.emplace(name, std::move(mesh)); }
        std::optional<std::reference_wrapper<Mesh>> GetMesh(const std::string & name) {
            if (m_meshes.find(name) == m_meshes.end())
                return std::nullopt;
            else 
                return *m_meshes.at(name);
        }
        void Foreach(std::function<void(std::string, std::shared_ptr<Mesh>)> && fn) { for (auto & [name, mesh] : m_meshes) { fn(name, mesh); } }
    private:
        std::unordered_map<std::string, std::shared_ptr<Mesh>> m_meshes;
    };
} // namespace SEngine


#endif